﻿<%@ Page Language="C#" MasterPageFile="../main.master" Inherits="VioletDevelopmentLaboratory.Net.Web.PageBase" %>

<script runat="server">
	protected void RemoveButton_Click(object sender, EventArgs e)
	{
		bool affacted = false;

		foreach (GridViewRow row in LogGridView.Rows)
		{
			if (((CheckBox)row.FindControl("SelectCheckBox")).Checked)
			{
				ExceptionLogFile.Delete(LogGridView.DataKeys[row.RowIndex].Value.ToString());
				affacted = true;
			}
		}

		if (affacted)
			LogGridView_DataBind();
	}

	protected void Page_Load(object sender, EventArgs e)
	{
		if (!Page.IsPostBack)
		{
			LogGridView_DataBind();
		}
	}

	protected void LogGridView_DataBind()
	{
		LogGridView.DataSource = ExceptionLogFile.GetLogs();
		LogGridView.DataBind();
	}
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="BodyContentPlaceHolder" runat="server">

	<h2>예외로그</h2>

	<fieldset>
		<table border="1" cellspacing="0" cellpadding="5" rules="all" style="border-collapse : collapse">
			<tr>
				<td>
					<asp:Button ID="RemoveButton" runat="server" Text="선택한 로그파일을 제거"
						OnClick="RemoveButton_Click" />
				</td>
			</tr>
		</table>

		<asp:GridView ID="LogGridView" runat="server"
			AutoGenerateColumns="False" DataKeyNames="FileName"
			ShowFooter="True" Width="100%" CellPadding="5" PageSize="20" 
			EmptyDataText="No Rows">
			<FooterStyle BackColor="Gray" />
			<Columns>
				<asp:TemplateField>
					<HeaderTemplate>
						<input id="SelectAllCheckBox" type="checkbox" value="" onclick="javascript:VWebGlobal_SelectCheckBox(this, '<%= LogGridView.ClientID %>', 'SelectCheckBox');" /><label for="SelectAllCheckBox">전체</label>
					</HeaderTemplate>
					<ItemTemplate>
						<asp:CheckBox ID="SelectCheckBox" runat="server" />
					</ItemTemplate>
					<HeaderStyle Width="50px" />
					<ItemStyle HorizontalAlign="Center" />
				</asp:TemplateField>
				<asp:TemplateField HeaderText="로그파일">
					<HeaderStyle />
					<ItemTemplate>
						<a href="detail.aspx?file=<%# Eval("FileName") %>"><%# Eval("FileName")%></a>
					</ItemTemplate>
				</asp:TemplateField>
				<asp:BoundField DataField="CreationTime" HeaderText="날짜" >
					<HeaderStyle Width="190px" />
					<ItemStyle HorizontalAlign="Center" />
				</asp:BoundField>
			</Columns>
			<HeaderStyle BackColor="Gray" />
			<AlternatingRowStyle BackColor="LightGray" />
		</asp:GridView>
	</fieldset>

</asp:Content>